//
//  TestView.swift
//  testSwift
//
//  Created by taoge on 2018/3/21.
//  Copyright © 2018年 FT. All rights reserved.
//

import UIKit

let Width = UIScreen.main.bounds.size.width
let Height = UIScreen.main.bounds.size.height

class TestView: UIView {

    var myImageView : UIImageView?
    var myButton : UIButton?
    var delegate : DelegateTool?
   
    override init(frame: CGRect) {
        super.init(frame: frame)
        creatUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func creatUI(){
        myImageView = UIImageView.init(frame: CGRect.init(x: 0, y:0, width: 100, height: 100))
        myImageView?.backgroundColor = UIColor.green
        self.addSubview(myImageView!)
        
        myButton = UIButton.init(frame: CGRect.init(x: 0, y: 100, width: 100, height: 20))
        myButton?.setTitle("taoge", for: UIControlState.normal)
        myButton?.backgroundColor = UIColor.orange
        myButton?.addTarget(self, action: #selector(clickButton(_:)), for: UIControlEvents.touchUpInside)
        self.addSubview(myButton!)
    }
    @objc func clickButton(_ sender:UIButton){
        delegate?.clickButton!(sender: sender)
    }

}
